public class Test {


    public MySingleList.Node getIntersectionNode(MySingleList.Node headA,MySingleList.Node headB) {
        int lenA = 0;
        int lenB = 0;
        MySingleList.Node pl = headA;
        MySingleList.Node ps = headB;
        while (pl != null) {
            lenA++;
            pl = pl.next;
        }
        while (ps != null) {
            lenB++;
            ps = ps.next;
        }
        int length = lenA - lenB;
        pl = headA;
        ps = headB;
        if (length < 0) {
            pl = headB;
            ps = headA;
            length = lenB - lenA;
        }
        while (length != 0) {
            pl = pl.next;
            length--;
        }
        while (pl != ps) {
            pl = pl.next;
            ps = ps.next;
        }
        return pl;
    }

    public static void main(String[] args) {
        MySingleList mySingleList1 = new MySingleList();
        mySingleList1.addIndex(0,14);
        mySingleList1.addIndex(1,24);
        mySingleList1.addIndex(2,54);
        mySingleList1.addIndex(3,24);
        mySingleList1.addIndex(4,14);
        mySingleList1.disPlay();
    }

    public static void main4(String[] args) {
        MySingleList mySingleList1 = new MySingleList();
        mySingleList1.addIndex(0,14);
        mySingleList1.addIndex(1,24);
        mySingleList1.addIndex(2,54);
        mySingleList1.addIndex(3,24);
        mySingleList1.addIndex(4,14);
        System.out.println(mySingleList1.isPalindrome());

    }

    public static void main3(String[] args) {
        MySingleList mySingleList1 = new MySingleList();
        mySingleList1.addIndex(0,14);
        mySingleList1.addIndex(1,24);
        mySingleList1.addIndex(2,34);
        mySingleList1.addIndex(3,44);
        mySingleList1.disPlay();
        System.out.println("------------");
        MySingleList mySingleList2 = new MySingleList();
        mySingleList2.addIndex(0,5);
        mySingleList2.addIndex(1,18);
        mySingleList2.addIndex(2,39);
        mySingleList2.addIndex(3,58);
        mySingleList2.disPlay();
        System.out.println("------------");
        MySingleList.Node ret = mySingleList1.mergeTwoList(mySingleList1.head,mySingleList2.head);
        mySingleList1.disPlay(ret);
    }

    public static void main2(String[] args) {
        MySingleList mySingleList = new MySingleList();
        mySingleList.addIndex(0,14);
        mySingleList.addIndex(1,24);
        mySingleList.addIndex(2,34);
        mySingleList.addIndex(3,44);
        mySingleList.disPlay();
        System.out.println("--------");
        MySingleList.Node ret = mySingleList.reverseList();
        mySingleList.disPlay(ret.next);
    }

    public static void main1(String[] args) {

        MySingleList mySingleList = new MySingleList();

        mySingleList.addIndex(0,14);
        mySingleList.addIndex(1,14);
        mySingleList.addIndex(1,14);
        /*try {
            mySingleList.addIndex(4,34);
        }catch (IndexOutOfException e) {
            e.printStackTrace();
        }*/
        mySingleList.disPlay();
        System.out.println("========");
        mySingleList.removeAllKey(14);
        mySingleList.disPlay();


        /*
        mySingleList.createList();
        mySingleList.addLast(18);
        */
        /*mySingleList.addFirst(88);
        mySingleList.disPlay();
        System.out.println(mySingleList.size());
        System.out.println(mySingleList.contains(13));
        mySingleList.addFirst(90);
        mySingleList.disPlay();
        mySingleList.addLast(80);
        mySingleList.disPlay();*/
    }

}
